<div class="cadremenu">

<a onclick="javascript:ajoutsoins()"  class="myButton"><img src="/butterflyportal/images/menu/cabinet_soin.png"   width="32">Nouveau Soin</a>
<a onclick="nouveauacte()"  class="myButton" ><img src="/butterflyportal/images/icons/ButterflyPortal-add.png" width="32" title="Ajouter nouveau acte"  >Nouveau Acte</a>
<!--<a onclick="nouveavance(<?=getParameter("dossierId")?>)"  class="myButton"><img src="/butterflyportal/images/menu/cabinet_depences.png" width="32" title="Ajouter nouvelle avance " >Ajouter une avance</a>
-->
<a onclick="javascript:ajoutdossierimages()"  class="myButton"><img src="/butterflyportal/images/menu/cabinet_soin_images.png"  width="32">Ajouter une image</a>
<a onclick="javascript:ajoutdossierradios()"  class="myButton"><img src="/butterflyportal/images/menu/cabinet_soin_radios.png"   width="32">Ajouter une radio</a>
<a onclick="javascript:ajoutdevis()"  class="myButton"><img src="/butterflyportal/images/menu/cabinet_devis.png"   width="32">Devis</a>

<a onclick="javascript:ajoutordonnance()"  class="myButton"><img src="/butterflyportal/images/menu/cabinet_soin_radios.png"   width="32">Ordonnance</a>

<a onclick="javascript:ajoutcertificat()"  class="myButton"><img src="/butterflyportal/images/menu/cabinet_certificat.png"   width="32">Cértificat</a>

<a onclick="javascript:dossierimages()" class="myButton"><img src="/butterflyportal/images/menu/cabinet_soin_images.png"  width="32">Images</a>
<a onclick="javascript:dossierradios()" class="myButton"><img src="/butterflyportal/images/menu/cabinet_soin_radios.png"  width="32">Radios</a>
<a onclick="javascript:dossieravances()" class="myButton"><img src="/butterflyportal/images/menu/cabinet_dossier_avance.png"  width="32">Avances</a>
<a onclick="javascript:rendezvous()" class="myButton"><img src="/butterflyportal/images/menu/cabinet_rendezvous.png"  width="32">Rendez-vous</a>


</div>


<script>




function nouveauacte(){
	var iframe = $('#ifrsoins');
	id=$("input[name='ButterflyPortal_sys_rec']:checked", iframe.contents()).val();

$("#bufferacte").html($("#newacte_"+id, iframe.contents()).html());
$("#bufferacte").dialog({
	autoOpen: true,
	height: 230,
	width: 400,
	modal: true,
	zIndex: 3999,
	buttons: {
		"Save": function() {
			newacteId=$("input[name='newacteradio']:checked").val();
			savenewacte(id,newacteId);
			$( this ).dialog( "close" );
		},
		Cancel: function() {
			$( this ).dialog( "close" );
		}
	}


	});
}





function savenewacte(soinId,newacteId)
{



	$.get("/portlet.php",
			{app: "cabinet",
			operation:"savenewacte",
			soinId:soinId,
			newacteId:newacteId
			},
			   function(data){
	            
				//alert(data);
			if (data=="ok") {
				document.getElementById("ifrsoins").contentDocument.location.reload(true);
				
				//alert("Nouveau Acte Ajouté");	

	
}else{
	
	alert("Problème survenu");
}

});

			
	
}


function nouveavance(dossierId){
	var iframe = $('#ifrsoins');
    id=$("input[name='ButterflyPortal_sys_rec']:checked", iframe.contents()).val();


	$("#bufferavance").html($("#newavance_"+id, iframe.contents()).html());
    $("#bufferavance").dialog({
        autoOpen: true,
        height: 160,
        width: 400,
        modal: true,
        zIndex: 3999,
        buttons: {
            "Ajouter": function() {
                montant=$("input[name='montant_"+id+"']").val();

             savenewavance(dossierId,montant);
             $( this ).dialog( "close" );
            },
            Cancel: function() {
                $( this ).dialog( "close" );
            }
        }


    });
}


function openflashdent(){

    

    $("#dentpicker").dialog({
        autoOpen: true,
        height: 400,
        width: 700,
        modal: true,
        zIndex: 3999,
        buttons: {
            Fermer: function() {
                $( this ).dialog( "close" );
            }
        }


    });
}
function savenewavance(dossierId,montant)
{

    $.get("/portlet.php",
        {app: "cabinet",
            operation:"savenewavance",
            dossierId:dossierId,
            montant:montant
        },
        function(data){
            //alert(data);
            if (data=="ok") {

              
              // alert("Nouveau avance Ajouté");


            }else{

                alert("Problème survenu");
            }

        });



}

function ajoutdossierimages(){
	var iframe = $('#ifrsoins');
    id=$("input[name='ButterflyPortal_sys_rec']:checked", iframe.contents()).val();

	
	url="/butterflyportal/iframe.php?table=cabinet_soin_images&filter=soinId="+id;

$("#cabinet_soin_images_iframe").attr('src',url); 


			$("#cabinet_soin_images_iframe_div").dialog({
				autoOpen: true,
				height: 500,
				width: 1000,
				modal: true,
				zIndex: 3999,
				buttons: {
					
					Close: function() {
						$( this ).dialog( "close" );
					}
				}


				});


	
}




function ajoutdossierradios(){
	var iframe = $('#ifrsoins');
    id=$("input[name='ButterflyPortal_sys_rec']:checked", iframe.contents()).val();

	
	url="/butterflyportal/iframe.php?table=cabinet_soin_radios&filter=soinId="+id;

$("#cabinet_soin_radios_iframe").attr('src',url); 


			$("#cabinet_soin_radios_iframe_div").dialog({
				autoOpen: true,
				height: 500,
				width: 1000,
				modal: true,
				zIndex: 3999,
				buttons: {
					
					Close: function() {
						$( this ).dialog( "close" );
					}
				}


				});


	
}

function ajoutordonnance(){
	var iframe = $('#ifrsoins');
    id=$("input[name='ButterflyPortal_sys_rec']:checked", iframe.contents()).val();
	url="/butterflyportal/iframe.php?table=cabinet_ordonnance_medicament&filter=soinId="+id;
	$("#cabinet_ordonnance_medicament_iframe").attr('src',url); 
			$("#cabinet_ordonnance_medicament_iframe_div").dialog({
				autoOpen: true,
				height: 500,
				width: 1000,
				modal: true,
				zIndex: 3999,
				buttons: {
						Close: function() {
						$( this ).dialog( "close" );
					}
				}
				});	
}


function ajoutdevis(){
	var iframe = $('#ifrsoins');
    id=$("input[name='ButterflyPortal_sys_rec']:checked", iframe.contents()).val();
	url="/butterflyportal/iframe.php?table=cabinet_devis&filter=soinId="+id;
	$("#cabinet_devis_iframe").attr('src',url); 
			$("#cabinet_devis_iframe_div").dialog({
				autoOpen: true,
				height: 500,
				width: 1000,
				modal: true,
				zIndex: 3999,
				buttons: {
					
					Close: function() {
						$( this ).dialog( "close" );
					}
				}


				});	
}

function ajoutcertificat(){
	var iframe = $('#ifrsoins');
    id=$("input[name='ButterflyPortal_sys_rec']:checked", iframe.contents()).val();
		  
	url="/butterflyportal/iframe.php?table=cabinet_certificat&filter=soinId="+id;
	$("#cabinet_certificat_iframe").attr('src',url); 
			$("#cabinet_certificat_iframe_div").dialog({
				autoOpen: true,
				height: 500,
				width: 1000,
				modal: true,
				zIndex: 3999,
				buttons: {
					
					Close: function() {
						$( this ).dialog( "close" );
					}
				}


				});	
}

function rendezvous(){
	var iframe = $('#ifrsoins');
    id=$("input[name='ButterflyPortal_sys_rec']:checked", iframe.contents()).val();

	
	url="/butterflyportal/iframe.php?table=cabinet_rendezvous&filter=dossierId=<?=getParameter("dossierId")?>";

$("#cabinet_rendezvous_iframe").attr('src',url); 


			$("#cabinet_rendezvous_iframe_div").dialog({
				autoOpen: true,
				height: 500,
				width: 1000,
				modal: true,
				zIndex: 3999,
				buttons: {
					
					Close: function() {
						$( this ).dialog( "close" );
					
					}
				}


				});


	
}

function dossieravances(){
	var iframe = $('#ifrsoins');
    id=$("input[name='ButterflyPortal_sys_rec']:checked", iframe.contents()).val();

	
	url="/butterflyportal/iframe.php?table=cabinet_dossier_avance&filter=dossierId=<?=getParameter("dossierId")?>";

$("#cabinet_dossier_avance_iframe").attr('src',url); 


			$("#cabinet_dossier_avance_iframe_div").dialog({
				autoOpen: true,
				height: 500,
				width: 1000,
				modal: true,
				zIndex: 3999,
				buttons: {
					
					Close: function() {
						$( this ).dialog( "close" );
					
					}
				}


				});


	
}




function ajoutsoins()

{

	var iframe = $('#ifrsoins');
    $("#Add", iframe.contents()).click();


	}

</script>	

<div id="bufferavance" title="Nouvelle avance"  style="display: none" >


</div>
<div id="bufferacte" title="Nouveau acte"  style="display: none" >


</div>


	<div id="cabinet_soin_images_iframe_div" title="Ajout d'images de soins"  style="display: none" class="portal_iframe" >
<iframe frameborder="0" id="cabinet_soin_images_iframe" src="" width="100%" style="border-width: 0px;" height="100%"></iframe>

</div>	


	<div id="cabinet_soin_radios_iframe_div" title="Ajout des radios de soins"  style="display: none" class="portal_iframe" >
<iframe frameborder="0" id="cabinet_soin_radios_iframe" src="" width="100%" style="border-width: 0px;" height="100%"></iframe>

</div>	


	<div id="cabinet_ordonnance_medicament_iframe_div" title="Générer une ordonnance"  style="display: none" class="portal_iframe" >
<iframe frameborder="0" id="cabinet_ordonnance_medicament_iframe" src="" width="100%" style="border-width: 0px;" height="100%"></iframe>

</div>	


<div id="cabinet_devis_iframe_div" title="Générer un devis"  style="display: none" class="portal_iframe" >

<iframe frameborder="0" id="cabinet_devis_iframe" src="" width="100%" style="border-width: 0px;" height="100%"></iframe>

</div>	


<div id="cabinet_rendezvous_iframe_div" title="Les Rendez-vous"  style="display: none" class="portal_iframe" >

<iframe frameborder="0" id="cabinet_rendezvous_iframe" src="" width="100%" style="border-width: 0px;" height="100%"></iframe>

</div>	


<div id="cabinet_dossier_avance_iframe_div" title="Les Avances"  style="display: none" class="portal_iframe" >

<iframe frameborder="0" id="cabinet_dossier_avance_iframe" src="" width="100%" style="border-width: 0px;" height="100%"></iframe>

</div>	


<div id="cabinet_certificat_iframe_div" title="Cértificat"  style="display: none" class="portal_iframe" >

<iframe frameborder="0" id="cabinet_certificat_iframe" src="" width="100%" style="border-width: 0px;" height="100%"></iframe>

</div>	













<?php 
$dossierId=getParameter("dossierId");
if ($dossierId){
?>






<div style="display: none">
<?php 

$SQL="SELECT

cabinet_soin_radios.image
FROM
cabinet_soins
INNER JOIN cabinet_soin_radios ON cabinet_soin_radios.soinId = cabinet_soins.id
WHERE
cabinet_soins.dossierId =  $dossierId";

$rs=ew_LoadRecordset($SQL);

while ($rs && !$rs->EOF)
{
	
	?>
	
	<a href="<?=getFilesPath("soinradios",false)."/".$rs->fields['image'];?>" class="soinimages" rel="radios"><img src="<?=getFilesPath("soinradios",false)."/".$rs->fields['image'];?>" width="32"></a>
	<?php 
	$rs->MoveNext();
	
}


$SQL="SELECT

cabinet_soin_images.image
FROM
cabinet_soins
INNER JOIN cabinet_soin_images ON cabinet_soin_images.soinId = cabinet_soins.id
WHERE
cabinet_soins.dossierId =  $dossierId";

$rs=ew_LoadRecordset($SQL);

while ($rs && !$rs->EOF)
{

	?>
	
	<a href="<?=getFilesPath("soinimages",false)."/".$rs->fields['image'];?>" class="soinimages" rel="images"><img src="<?=getFilesPath("soinimages",false)."/".$rs->fields['image'];?>" width="32"></a>
	<?php 
	$rs->MoveNext();
	
}

?>

</div>

<script type="text/javascript">

function dossierimages(){

	

	$("a[rel='images']").click();
}

function dossierradios(){

	if ($("a[rel='radios']")) $("a[rel='radios']").click(); else alert("ok");
}
function ajoutsalleattente(){





	$.get("/portlet.php",
	{app: "cabinet",
	operation:"ajoutsalleattente",
	dossierId:<?=$dossierId?>
	},
	   function(data){


		parent.document.location="?table=cabinet_attente&filter=1";


				});


	
	
}




$(document).ready(function() {

	
	
	$("a.soinimages").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});
	
});

</script>


<?php } ?>
